<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <title>商户中心-消费记录</title>
    <?php PrintPageHead(); ?>
</head>
<body>


<?php
if (!array_key_exists("公众号ID",$_SESSION)) {
     header("Location:back.php");
}
$bm=new C后台管理员();
$retdata=$bm->f显示推广用户($_GET['f']);
//$do=new BoKeywords();
$ret = $retdata;

$busFlag='';

?>
<script type="text/javascript">
    <!--
    function formCheck(form) {
        if (form['name'].value == '') {
            alert("请输入商品名称！");
            return false;
        }else{
            return true;
        }
    }
    function closeWind(){

        if(typeof(WeixinJSBridge)=='undefined')
            window.close();
        else

            WeixinJSBridge.invoke('closeWindow',{},function(res){

                //alert(res.err_msg);
                return true;
            });
    }
    -->
</script>
<div class="container-fluid">
        <?php include_once 'back_header.php'; ?>

    <div class="panel panel-primary">
        <div class="panel-heading text-center"><h3 class="panel-title">数据汇总</h3></div>
        <div class="panel-body">
            <div class="form-tip_l"><input type="text" name="stime" placeholder="开始日期" id="stime" value="<?php echo Date('Y-m-d'); ?>" readonly> - <input type="text" placeholder="结束日期" id="etime" name="etime" readonly value="<?php echo Date('Y-m-d'); ?>">&nbsp;&nbsp;<input type="button" value="查询" onclick="getData()">&nbsp;&nbsp;<input type="button" value="昨日明细" onclick="getZuoData()"></div><br/>
            <div id="divmain1">
            </div>

        </div>
    </div>
    <form>
        <input type="hidden" name="gong" value="<?=$_SESSION['公众号']?>" />
    </form>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="../resource/js/jquery-1.11.1.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="../resource/js/bootstrap.min.js"></script>
<script src="../resource/js/hermes.js"></script>
<link href="../resource/js/calendar/calendar-blue.css" type="text/css" rel="stylesheet">
<script src="../resource/js/calendar/calendar.js" type="text/javascript"></script>
<script language="javascript">
    //时间控件
    Calendar.setup({
        inputField : "stime",
        ifFormat : "%Y-%m-%d",
        showsTime : "true",
        timeFormat : "24"
    });

    Calendar.setup({
        inputField : "etime",
        ifFormat : "%Y-%m-%d",
        showsTime : "true",
        timeFormat : "24"
    });

    function getstime(strr) {
        var datetime = new Date(strr);
        datetime = datetime.getTime()+86400*1000;
        datetime = new Date(datetime);
        datetime = formatDate(datetime);
        return datetime;
    }

    function   formatDate(now)   {
        var   year=now.getFullYear();
        var   month=now.getMonth()+1;
        var   date=now.getDate();
        var   hour=now.getHours();
        var   minute=now.getMinutes();
        var   second=now.getSeconds();
        if(month<10) {
            month="0"+month;
        }
        if(date<10) {
            date="0"+date;
        }
        return   year+"-"+month+"-"+date;
    }

    function getData() {
        var stime = $('input[name="stime"]').val();
        var etime = $('input[name="etime"]').val();

        if(stime == '') {
            alert('开始日期不能为空!');
            return false;
        }
        if(etime == '') {
            alert('结束日期不能为空!');
            return false;
        }

        var arrStart = stime.split("-");
        var tmpIntStartYear = parseInt(arrStart[0],10);
        var tmpIntStartMonth = parseInt(arrStart[1],10);
        var tmpIntStartDay = parseInt(arrStart[2],10);

        var arrEnd = etime.split("-");
        var tmpIntEndYear = parseInt(arrEnd[0],10);
        var tmpIntEndMonth = parseInt(arrEnd[1],10);
        var tmpIntEndDay = parseInt(arrEnd[2],10);

        if(tmpIntStartYear > tmpIntEndYear) {
            alert("开始日期不能晚于结束日期");
            return false;
        }

        if(tmpIntStartYear == tmpIntEndYear) {
            if(tmpIntStartMonth > tmpIntEndMonth) {
                alert("开始日期不能晚于结束日期");
                return false;
            }
        }
        if(tmpIntStartYear == tmpIntEndYear) {
            if(tmpIntStartMonth == tmpIntEndMonth) {

                if(tmpIntStartDay > tmpIntEndDay) {
                    alert("开始日期不能晚于结束日期");
                    return false;
                }
            }
        }
        etime = getstime(etime);
//        location.href='index.php?state=Seller5DetailData&openId=<?//=$openId?>//&startdate='+stime+'&enddate='+etime;
        $.post('BackSellerAjax.php',{stime:stime,etime:etime,'businessFlag':'ac查找用户推广详细','二维码编号':'<?=$_GET['f']?>'},function(data) {

          //  alert(data[0]['开始时间']);
            createdate(data);
        },'json')
    }

    function GetDateStr(AddDayCount) {
        var dd = new Date();
        dd.setDate(dd.getDate()+AddDayCount);//获取AddDayCount天后的日期
        var y = dd.getFullYear();
        var m = dd.getMonth()+1;//获取当前月份的日期
        var d = dd.getDate();
        if(m<10) {
            m="0"+m;
        }
        if(d<10) {
            d="0"+d;
        }
        return y+"-"+m+"-"+d;
    }
    var datetcol1 = 0;
    var datetcol2 = 1;
    var datetcol3= 2;

    function getZuoData() {
        var stime = GetDateStr(-1);
        var etime = GetDateStr(-1);
        $('input[name="stime"]').val(stime);
        $('input[name="etime"]').val(etime);
        etime = getstime(etime);
        $.post('BackSellerAjax.php',{stime:stime,etime:etime,'businessFlag':'ac查找用户推广详细','二维码编号':'<?=$_GET['f']?>'},function(data) {
            createdate(data);
        },'json')
    }

    function createdate(str) {
        $('#divmain1').html('');
        var table = $.makeTable(str);
        $(table).appendTo("#divmain1");


        var trs = $("#divmain1 table tr:eq(0)");//第0行
        $.each(trs,function(idx,atr){
            var atd = $(atr).children()[datetcol1];
            $(atd).hide();
            var atd = $(atr).children()[datetcol2];
            $(atd).hide();
            var atd = $(atr).children()[datetcol3];
            $(atd).hide();


        })

        var trs = $("#divmain1 table tr:gt(0)");//行号大于=1的所有行
        $.each(trs,function(idx,atr){
            var atd = $(atr).children()[datetcol1];
            sid = $(atd).text();
            $(atd).hide();

            var atd = $(atr).children()[datetcol2];
            startdate = $(atd).text();
            $(atd).hide();

            var atd = $(atr).children()[datetcol3];
            enddate = $(atd).text();
            $(atd).hide();


        })
    }


    $(document).ready(function(){

        createdate(<?=$ret?>);


    });
    function returnBack(){

        window.history.back();
    }
</script>
</body>
</html>